package com.acwing.partition20;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author `RKC`
 * @date 2022/1/17 19:49
 */
public class AC1934贝茜放慢脚步 {

    private static final int N = 10010;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        int n = Integer.parseInt(reader.readLine());
        List<Integer> times = new ArrayList<>(), dist = new ArrayList<>();
        dist.add(1000);
        for (int i = 0; i < n; i++) {
            String[] s = reader.readLine().split("\\s+");
            int k = Integer.parseInt(s[1]);
            if ("T".equals(s[0])) times.add(k);
            else dist.add(k);
        }
        writer.write(String.format("%.0f\n", resolve(times, dist)));
        writer.flush();
    }

    private static double resolve(List<Integer> times, List<Integer> dist) {
        Collections.sort(times);
        Collections.sort(dist);
        //t表示已经花费的时间，s表示已经走过的距离，v表示当前速度的倒数
        double t = 0, s = 0, v = 1;
        int i = 0, j = 0;
        while (i < times.size() || j < dist.size()) {
            //优先选择事件发生靠前的；对于时间来说，如果时间事件时间间隔的时间差小于了距离事件距离间隔除以速度，此时的时间事件发生在前面
            if (j == dist.size() || (i < times.size() && times.get(i) - t < (dist.get(j) - s) * v)) {
                s += (times.get(i) - t) / v;
                t = times.get(i);
                v++;
                i++;
            } else {
                t += (dist.get(j) - s) * v;
                s = dist.get(j);
                v++;
                j++;
            }
        }
        return t;
    }
}
